Skip to content

Optimize GAE startup and fix OGC/migration regressions#594

Merged
jirhiker merged 2 commits intostagingfrom
deployment-optimizations
Mar 10, 2026
Merged

Optimize GAE startup and fix OGC/migration regressions#594
jirhiker merged 2 commits intostagingfrom
deployment-optimizations

Conversation

@jirhiker
Copy link
Copy Markdown
Member

@jirhiker jirhiker commented Mar 10, 2026

Summary

This PR reduces App Engine cold-start overhead, simplifies the current single-service deployment path, and fixes regressions uncovered during the startup refactor.

What changed

Startup and runtime

  • keeps the app on one service and lazy-loads admin on first /admin access
  • keeps GCS imports off the main startup path
  • adds startup and per-request timing logs to distinguish cold vs warm behavior
  • adds a warmup endpoint and keeps the business-hours warmup strategy
  • makes normal API startup independent of SESSION_SECRET_KEY; /admin now returns a clear 503 when that secret is unset

Deploy and local dev

  • simplifies Docker Compose back to db + app
  • keeps entrypoint.sh parameterized, with migrations enabled by default for local dev
  • hardens App Engine CD cleanup so first deploy and single-version cases do not fail
  • stops workflows from touching dispatch config

Database and OGC fixes

  • adds a follow-up Alembic migration to rebuild ogc_water_elevation_wells for databases that recorded the earlier revision but still have the old materialized view definition
  • adds integration coverage for the materialized view schema
  • fixes the OGC regression caused by the env-helper refactor by switching query boolean parsing to services.env.to_bool

Code cleanup

  • extracts lightweight env parsing into services/env.py
  • keeps the low-risk lazy-loading improvements that survived the earlier service-splitting experiment
  • adds targeted tests for lazy admin loading and request timing

Validation

Ran:

  • pytest tests/test_lazy_admin.py tests/test_request_timing.py tests/test_ogc.py tests/test_admin_views.py tests/integration/test_alembic_migrations.py tests/test_cli_commands.py -q
  • result: 55 passed, 3 skipped
  • pytest tests/test_ogc.py -q
  • result: 12 passed, 2 skipped

Also verified:

  • App Engine template and workflow YAML parsing
  • targeted compile checks on touched Python files

Notes

  • no new required deploy secrets were introduced
  • App Engine runtime service account behavior remains aligned with the prior template using CLOUD_SQL_USER
  • the main remaining cold-start cost is pygeoapi, not admin

Copilot AI review requested due to automatic review settings March 10, 2026 15:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces cold-start overhead and simplifies a single-service GAE deployment. The specific diff shown here fixes an OGC import regression by correcting the import path for to_bool — moving it from the nonexistent services.util.to_bool to the correct services.env.to_bool. The broader PR description covers lazy-loading of admin routes, GAE deploy cleanup, Alembic migration additions, and startup/request timing logs, but only the query_helper.py change is included in this diff.

Changes:

  • Fixes to_bool import in services/query_helper.py from services.util (where it never existed) to services.env (the correct location)

You can also share your feedback on Copilot code review. Take the survey.

@jirhiker jirhiker changed the title Reduce cold-start overhead and simplify single-service deployment Optimize GAE startup and fix OGC/migration regressions Mar 10, 2026
@jirhiker jirhiker merged commit ccc295f into staging Mar 10, 2026
8 checks passed
@TylerAdamMartinez TylerAdamMartinez deleted the deployment-optimizations branch March 12, 2026 17:13
@TylerAdamMartinez TylerAdamMartinez restored the deployment-optimizations branch March 12, 2026 17:13
@TylerAdamMartinez TylerAdamMartinez deleted the deployment-optimizations branch March 12, 2026 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants